package com.onpositive.data.diskstorage;

import java.util.Collection;
import java.util.HashMap;

import com.onpositive.data.IPropertyMetadata;
import com.onpositive.data.ISeekableAccess;

public class StoredMetadata implements IPropertyMetadata {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private HashMap<String,Object> map = new HashMap<String, Object>() ;
	
	private String id ;
	private int type ;
	
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public void setId(String id) {
		this.id = id;
	}
	public StoredMetadata( ISeekableAccess file )
	{
				
	}
	public StoredMetadata()
	{
	}
	@Override
	public String id() {
		return id;
	}
	
	@Override
	public String toString() {
		return id;
	}

	@Override
	public Collection<String> keys() {
		return map.keySet();
	}

	@Override
	public Class<?> type() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Object getMetaPropertyValue(String key) {
		if(key.equals("id"))
			return this.id() ;
		
		return map.get(key);
	}
	
	public void setVlaue( String key, Object value ){
		map.put( key,value ) ;
	}
	@Override
	public Object getValue(Object obj) {
		return map.get(obj);
	}
	
	public void update(StoredMetadata m){
		map.clear();
		map.putAll(m.map);
	}

}
